/* 减少消息内容中元素的垂直间距 */
.message-bubble div p {
    margin: 0.2em 0; /* 减少段落间距 */
}

.message-bubble div ul,
.message-bubble div ol {
    margin: 0.2em 0;
    padding-left: 1.5em; /* 减少列表缩进 */
}

.message-bubble div li {
    margin: 0.25em 0; /* 减少列表项间距 */
}

.message-bubble div h1,
.message-bubble div h2,
.message-bubble div h3,
.message-bubble div h4,
.message-bubble div h5,
.message-bubble div h6 {
    margin: 0.75em 0 0.5em 0; /* 减少标题间距 */
}

/* 控制整体消息内容的间距 */
.message-content {
    margin-bottom: 5px; /* 调整消息之间的间距 */
}

/* 调整代码块的间距 */
.message-bubble div pre {
    margin: 0.2em 0;
}
/* 流式输出相关样式 */

/* 打字指示器 */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    height: 20px;
    margin-left: 5px;
}

.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin: 0 2px;
    background-color: #8c8c8c;
    border-radius: 50%;
    opacity: 0.4;
    animation: typingAnimation 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingAnimation {
    0% {
        transform: scale(1);
        opacity: 0.4;
    }
    50% {
        transform: scale(1.5);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 0.4;
    }
}

/* 流式内容样式 */
.streaming-content {
    min-height: 1em;
    white-space: pre-wrap;
    word-break: break-word;
}

/* 代码块样式 */
.streaming-content pre {
    background-color: #f8f8f8;
    padding: 10px;
    border-radius: 5px;
    overflow-x: auto;
    margin: 10px 0;
    position: relative;
}

.streaming-content pre code {
    color: #333;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
    line-height: 1.5;
}

/* 停止生成按钮 */
.btn-stop-generation {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background-color: #f44336;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 10;
    transition: all 0.3s ease;
}

.btn-stop-generation:hover {
    background-color: #d32f2f;
    transform: scale(1.1);
}

.btn-stop-generation i {
    font-size: 16px;
}

/* 生成已停止标记 */
.generation-stopped {
    color: #f44336;
    font-style: italic;
    margin-top: 5px;
    padding: 3px 8px;
    background-color: rgba(244, 67, 54, 0.1);
    border-radius: 4px;
    display: inline-block;
}

/* 代码块工具栏 */
.code-toolbar {
    display: flex;
    justify-content: flex-end;
    padding: 3px;
    background-color: #e0e0e0;
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
}

.code-toolbar button {
    background: none;
    border: none;
    color: #555;
    cursor: pointer;
    padding: 2px 5px;
    font-size: 12px;
}

.code-toolbar button:hover {
    color: #000;
}

/* 高亮动画 */
@keyframes highlight {
    0% {
        background-color: rgba(255, 236, 179, 0.5);
    }
    50% {
        background-color: rgba(255, 236, 179, 0.8);
    }
    100% {
        background-color: rgba(255, 236, 179, 0);
    }
}

/* 新令牌高亮 */
.token-new {
    animation: highlight 1.5s ease-in-out;
}

/* 光标闪烁 */
.cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background-color: #333;
    vertical-align: middle;
    margin-left: 2px;
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.message-bubble.assistant.error {
    background-color: #fff0f0;
    border: 1px solid #ffcccc;
}

.error-message {
    color: #d32f2f;
    font-weight: normal;
}

.error-message i {
    margin-right: 5px;
}